from pydantic import BaseModel

##################
## 验证层(数据处理)
##################


# User
class ReadUser(BaseModel):
    id: int
    name: str
    fullname: str = None


class ReadUserToRole(ReadUser):
    roles: list['ReadRole']


class ReadUserToRoleToPowers(ReadUser):
    roles: list['ReadRoleToPower']


class WriteUser(BaseModel):
    name: str
    fullname: str = None

class HasPermission(BaseModel):
    user_id: int
    power_name: str


class UpdateUser(BaseModel):
    name: str

# Role
class ReadRole(BaseModel):
    id: int
    name: str


class ReadRoleToPower(ReadRole):
    powers: list['ReadPower']


class WriteRole(BaseModel):
    name: str


# Power
class ReadPower(BaseModel):
    id: int
    name: str

class WritePower(BaseModel):
    name: str